<template>
  <div>
    <el-tree
      ref="infoCateTree"
      :data="data"
      :props="defaultProps"
      node-key="catId"
      @node-click="handlerNodeClick"
      :expand-on-click-node="false"
    >
    </el-tree>
  </div>
</template>

<script>
export default {
  
  data() {
    return {
      data: [],
      defaultProps: {
        label: "catName",
        children: "children",
        expandedKeys: [],
      },
    }
  },

  methods: {
    getMenus() {
      this.dataListLoading = true;
      this.$http({
        url: this.$http.adornUrl("/admin/info/category/list/tree"),
        method: "get",
      }).then(({ data }) => {
        // console.log("成功获取到数据");
        console.log("从后端获取数据成功：", data);
        this.data = data.data;
      });
      this.expandedKeys = [];
    },

    /**
     * 节点被点击时，回调，并向父组件传递值
     */
    handlerNodeClick(data, node, component){
        // console.log("信息种类菜单中节点被点击", data, node)
        //
        this.$emit("tree-node-click", data, node, component)
    },
  },

  created() {
    this.getMenus();
  },
};
</script>

<style>
</style>